<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
					<div class="select-list">
						<ul>
							<li>
								充电模式：<select id="chargeMs" name="chargeMs" th:with="type=${@dict.getType('charge_ms')}">
								<option value="">请选择</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
                                <input type="hidden" name="beginTime" id="beginTime" th:value="${beginTime}" />
                                <input type="hidden" name="endTime" id="endTime" th:value="${endTime}" />
                                桩位编号：<input type="text" name="stakeCode" id="stakeCode" th:value="${stakeCode}" placeholder="桩位编号"/>
							</li>
							<li>
								充电枪号：<!--<input type="text" id="gunCode" name="gunCode" placeholder="充电枪编号"/>-->
								<select id="gunCode" name="gunCode" th:with="type=${@dict.getType('gun_code')}">
									<option value="">请选择</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								充电状态：<select id="chargeState" name="chargeState" th:with="type=${@dict.getType('order_status')}">
								<option value="">请选择</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
								支付方式：<select name="payType" th:with="type=${@dict.getType('station_payType')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
		
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
		        <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="statistics:stake:exportDetail">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
				<!--style="table-layout: fixed;" 设置固定列宽-->
				<table id="bootstrap-table"  style="table-layout: fixed;" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:inline="javascript">
        var order_status = [[${@dict.getType('order_status')}]];
        var pay_type = [[${@dict.getType('station_payType')}]];
        var charge_ms = [[${@dict.getType('charge_ms')}]];
        var end_type = [[${@dict.getType('end_type')}]];
        var gun_code = [[${@dict.getType('gun_code')}]];
        var refund_state = [[${@dict.getType('refund_state')}]];
        var prefix = ctx + "statistics/stake";
		$(function() {
		    var options = {
		        url: prefix + "/listDetail",
		        exportUrl: prefix + "/exportDetail",
                queryParams: queryParams,
		        //sortName: "stakeCode",
		        modalName: "单桩统计报表明细",
		        search: false,
		        showExport: false,
		        columns: [
		        {
		            field: 'stakeCode',
                    width: 100,
		            title: '桩号'
		        },
		        {
		            field: 'gunCode',
                    width: 100,
		            title: '充电枪号',
                    align: 'center',
                    formatter: function(value) {
                        return $.table.selectDictLabel(gun_code, value);
                    }
		        },
		        {
		            field: 'stationName',
                    width: 200,
		            title: '站名'
		        },
				{
					field: 'chargeMs', // 列字段名
					title: '充电模式',// 列标题
                    width: 100,
					align: 'center',
					formatter: function(value) {
						return $.table.selectDictLabel(charge_ms, value);
					}
				},
		        {
		            field: 'startTime',
                    width: 200,
		            title: '充电开始时间'
		        },
		        /*{
		            field: 'endTimePlan',
                    width: 200,
		            title: '计划结束时间'
		        },*/
		        {
		            field: 'endTime',
                    width: 200,
		            title: '实际结束时间'
		        }
				,{
					field: 'endType', // 列字段名
					title: '结束方式' ,// 列标题
                    width: 100,
					align: 'center',
					formatter: function(value) {
						return $.table.selectDictLabel(end_type, value);
					}
				},
				{
					field: 'chargeState', // 列字段名
					title: '充电状态' ,// 列标题
                    width: 100,
					align: 'center',
					formatter: function(value) {
						return $.table.selectDictLabel(order_status, value);
					}
				},
		        {
		            field: 'chargeDn',
                    width: 100,
		            title: '充电电量(度)'
		        },
		        {
		            field: 'chargeLong',
                    width: 100,
		            title: '充电时长',
                    align: 'right',
                    formatter: function (value, row, index) {
                        return formatSeconds(value)
                    }
		        },
		        {
		            field: 'userPhone',
                    width: 100,
		            title: '用户手机号'
		        },
		        {
		            field: 'payNumberPlan',
                    width: 100,
		            title: '应收金额(元)'
		        },
				{
					field: 'payNumber',
                    width: 100,
					title: '实收金额(元)',
                    formatter: function(value, row, index) {
                        var offMoney = row.offMoney ==null ? 0 : row.offMoney;
                        var payNumberPlan = row.payNumberPlan ==null ? 0 : row.payNumberPlan;
                        var value = (payNumberPlan-offMoney).toString();
                        value = value.substr(0,value.indexOf(".")+3);
                        return value;
                    }
                },
		        {
		            field: 'offType',
                    width: 100,
		            title: '优惠方式'
		        },
				{
					field: 'offMoney', // 列字段名
					width: 100,
					title: '优惠金额(元)' // 列标题
				},
				{
					field: 'payType', // 列字段名
					title: '支付方式', // 列标题
                    width: 100,
					align: 'center',
					formatter: function(value) {
						return $.table.selectDictLabel(pay_type, value);
					}
				}/*, {
					field: 'refundPrice', // 列字段名
					title: '退款金额(元)', // 列标题
					align: 'center',
					width: 100,
				}, {
					field: 'state', // 列字段名
					title: '退款状态', // 列标题
					align: 'center',
					width: 150,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(refund_state, value);
					}
				}, {
					field: 'refundReason', // 列字段名
					title: '退款原因', // 列标题
					align: 'center',
					width: 100
				}*/
		        ]
		    };
		    $.table.init(options);
		});

        function queryParams(params) {
            return {
                stakeCode:       $("#stakeCode").val(),
                beginTime:       $("#beginTime").val(),
                endTime:       $("#endTime").val(),
                pageSize:       params.limit,
                pageNum:        params.offset / params.limit + 1,
                searchValue:    params.search,
                orderByColumn:  params.sort,
                isAsc:          params.order
            };
        }

	</script>
</body>
</html>